<?php session_start(); ?>
<?php
 if(!$_SESSION['uname']){
  echo "你没有权限访问此页面!";
  return false;
}
?>
<?php include("../inc/db_config.inc"); ?>
<?php
if(isset($_REQUEST['pid'])&&$_REQUEST['pid']!=""){
    $post_pid=$_REQUEST['pid'];
}else{
    echo "文章ID不能为空<a href='javascript:history.back()'>返回</a>";
    return false;
}
if(isset($_REQUEST['title'])&&$_REQUEST['title']!=""){
	$title=$_REQUEST['title'];
    $post_title=trim($title);
}else{
    echo "标题不能为空<a href='javascript:history.back()'>返回</a>";
    return false;
}
if(isset($_REQUEST['type'])&&$_REQUEST['type']!=""){
    $post_type=$_REQUEST['type'];
}else{
    echo "请选择文章分类<a href='javascript:history.back()'>返回</a>";
    return false;
}
if(isset($_REQUEST['content'])&&$_REQUEST['content']!=""){
		if (get_magic_quotes_gpc()) {
			//$notice_cont = addslashes($_REQUEST['content']);
			$post_content =  stripslashes(trim($_REQUEST['content']));
		} else {
			$post_content = trim($_REQUEST['content']);
		}
		$post_content = str_replace('\'', "''", $post_content);
}else{
    echo "内容不能为空<a href='javascript:history.back()'>返回</a>";
    return false;
}
if(isset($_REQUEST['allowComment'])){
    $post_allowComment=$_REQUEST['allowComment'];

}
if(isset($_REQUEST['commentAudit'])){
    $post_commentAudit=$_REQUEST['commentAudit'];
}
date_default_timezone_set("Asia/Shanghai"); //北京时间
$post_created=date("Y-m-d H:i:s");
$post_pubid=1;
$post_audit=1;

$result_post=mysql_query("update info set title='$post_title',pubid='$post_pubid',content='$post_content',type='$post_type',audit='$post_audit',allowComment='$post_allowComment',comment_audit='$post_commentAudit' where id=$post_pid");
if(mysql_affected_rows()>0){
    //$getID=mysql_insert_id();
    $ref=$_SERVER['HTTP_REFERER'];
    echo "更新成功!页面会在1秒钟后自动返回.<script type='text/javascript'>setTimeout(function(){window.location.href='$ref'},1000)</script>";
}else{
    echo "更新失败!<a href='javascript:history.back()'>返回</a>";
    echo mysql_error();
}
 ?>